package com.chalmers.foa.gui.menus;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.chalmers.foa.R;
import com.chalmers.foa.core.Game;

public class Menu extends Activity {
	Button startGameButton,selectLevelButton,settingsButton,exitGameButton;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);// Forces landscape mode
        setContentView(R.layout.menu);
        init();
    }
	/**
	 * Initializes Menu variables
	 */
    private void init(){
    	startGameButton = (Button)findViewById(R.id.start_game_button);
    	selectLevelButton = (Button)findViewById(R.id.select_level_button);
    	settingsButton = (Button)findViewById(R.id.settings_button);
    	exitGameButton = (Button)findViewById(R.id.exit_game_button);

    	startGameButton.setOnClickListener(buttonListener);
    	selectLevelButton.setOnClickListener(buttonListener);
    	settingsButton.setOnClickListener(buttonListener);
    	exitGameButton.setOnClickListener(buttonListener);
    }

	/**
	 * Listen for button clicks
	 */
    OnClickListener buttonListener = new OnClickListener(){

		@Override
		public void onClick(View v) {
			if(v.equals(startGameButton)){
				Intent startGameActivity = new Intent(Menu.this,Game.class);
				startActivity(startGameActivity);
			}
			else if(v.equals(selectLevelButton)){
				Intent selectLevelActivity = new Intent(Menu.this,SelectLevel.class);
				startActivity(selectLevelActivity);
			}
			else if(v.equals(settingsButton)){
				Intent settingsActivity = new Intent(Menu.this,Settings.class);
				startActivity(settingsActivity);
			}
			else{
				finish();
			}
		}
    
    };
}